import toolMgr from '@/biz/base/tool.js'
import dt from '@dt/dt'
import ruleOpt from '@/biz/option/rule.js'

function options(files) {
  let api = toolMgr.unloadFile()
  return [
    {
      title: '我司盖章附件',
      key: 'files',
      upload: {
        title: '附件上传',
        api,
        files,
        multiple: true,
        preview: (file) => {
          toolMgr.downloadFile(file.url, file.name)
        }
      },
      rules: [ruleOpt.required('请上传附件', 'array')],
      data: {
        to: (v) => {
          return {
            files: v.map((item) => {
              return {
                name: item.name,
                url: item.response?.data.imageURL ?? item.url
              }
            })
          }
        }
      }
    }
  ]
}

export default {
  options
}
